<template>
  <div class="container">
    <el-drawer
      custom-class="wxkj-drawer"
      title="编辑"
      :before-close="drawerClose"
      :visible.sync="drawerShow"
      size="500"
    >
      <div class="drawer-content">
        <div class="ml30 mb20 f14">添加后，同事可通过改手机号和验证码登录</div>
        <el-form ref="form"
         :model="form"
          :rules="formRules" label-width="120px">
          <el-form-item label="登录手机号：" required prop="phone">
            <el-input placeholder="" v-model="form.phone"></el-input>
          </el-form-item>
          <el-form-item label="姓名：" required prop="userName">
            <el-input placeholder="" v-model="form.userName"></el-input>
          </el-form-item>
          <el-form-item label="接收简历邮箱：" required prop="mailbox">
            <el-input placeholder="" v-model="form.mailbox"></el-input>
          </el-form-item>
          <el-form-item label="职位：" required prop="job">
            <el-input placeholder="" v-model="form.job"></el-input>
          </el-form-item>
          <el-form-item class="fr">
            <el-button @click="drawerClose">取消</el-button>
            <el-button type="primary" @click="submitForm">确定</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import {edit} from '@/api/colleague';
export default {
  components: {},
  props: {},
  data() {
    return {
      form: {
        phone: '',
        userName: '',
        mailbox: '',
        job: ''
      },
      formRules: {
        phone: [{ required: true, message: "请填写手机号" }],
        userName: [{ required: true, message: "请填写姓名" }],
        mailbox: [{ required: true, message: "请填写邮箱" }],
        job: [{ required: true, message: "请填写职位" }],
      },
      drawerShow: false,
    };
  },
  // 方法
  methods: {
    show(data) {
      this.drawerShow = true;
      this.form = data;
    },
     drawerClose() {
      this.$nextTick(() => {
        this.$refs.form.resetFields();
        this.form = this.$options.data().form;
      });
      this.drawerShow = false;
      this.$emit("refresh");
    },
    // 提交
    submitForm() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          let form = JSON.parse(JSON.stringify(this.form));
          form.updateTime = "";
          form.createTime = "";
          edit(form).then((res) => {
              this.$message({
                message: "修改成功",
                type: "success",
                });
                this.drawerClose();
              
            });
        }
      });
    },
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  // 销毁
  destroyed() {},
};
</script>
<style lang="scss" scoped>
</style>